package com.sptpc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.sptpc.domain.Product;
import com.sptpc.service.ProductService;

@Controller
public class PraductController {
	@Autowired
	private ProductService productService;
	
	
	@RequestMapping(value="findProById",method=RequestMethod.GET)
	public ModelAndView FindProductById(String pid){
		System.out.println(pid);
		ModelAndView mv = null;
		Product product = productService.finProductById(pid);
		if(product != null){
			//视图
			mv = new ModelAndView("product_info");
			mv.addObject("product",product);
		}
		return mv;
	}
}
